﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Xml;

namespace Microsoft.MSE.Catalog.Contracts.Services
{
    /// <summary>
    /// 
    /// </summary>
    [ServiceContract(Namespace = Schemas.Services, Name = "DesignModel")]
    public interface IDesignModel
    {
        [OperationContract]
        ChannelList ListChannels();

        [OperationContract]
        Guid CreateChannel(Channel channel);

        [OperationContract]
        void DeleteChannel(Guid ID);

        [OperationContract]
        Channel UpdateChannel(Channel channel);

        [OperationContract]
        Channel GetChannel(Guid ID);

        [OperationContract]
        PolicyList ListPolicies();

        [OperationContract]
        Guid CreatePolicy(Policy policy);

        [OperationContract]
        void DeletePolicy(Guid ID);

        [OperationContract]
        Policy UpdatePolicy(Policy policy);

        [OperationContract]
        RuntimeServerList ListRuntimeServers();

        [OperationContract]
        Guid CreateSchema(Schema schema);

        [OperationContract]
        Guid CreateRuntimeServer(RuntimeServer runtimeServer);

        [OperationContract]
        void DeleteRuntimeServer(Guid ID);

        [OperationContract]
        RuntimeServer UpdateRuntimeServer(RuntimeServer runtimeServer);

        [OperationContract]
        RuntimeServer GetRuntimeServer(Guid ID);

        [OperationContract]
        RuntimeServer GetRuntimeServerWithoutEndpointWSDL(Guid ID);

        [OperationContract]
        EndpointList ListEndpoints();

        [OperationContract]
        EndpointList ListEndpointsForRuntimeServer(string runtimeServerName);

        [OperationContract]
        Guid CreateEndpoint(Endpoint endpoint);

        [OperationContract]
        void DeleteEndpoint(Guid ID);

        [OperationContract]
        Endpoint UpdateEndpoint(Endpoint endpoint);

        [OperationContract]
        Endpoint GetEndpointWithoutWSDL(Guid ID);

        [OperationContract]
        Endpoint GetEndpoint(Guid ID, Guid runtimeServerID);

        [OperationContract]
        MSEBindingList ListMSEBindings();

        [OperationContract]
        Guid CreateMSEBinding(MSEBinding binding);

        [OperationContract]
        void DeleteMSEBinding(Guid ID);

        [OperationContract]
        MSEBinding UpdateMSEBinding(MSEBinding binding);

        [OperationContract]
        MSEBinding GetMSEBinding(Guid ID);

        [OperationContract]
        Guid CreateMSEBindingElement(MSEBindingElement bindingElement);

        [OperationContract]
        MSEBindingElement UpdateMSEBindingElement(MSEBindingElement bindingElement);

        [OperationContract]
        void DeleteMSEBindingElement(Guid ID);

        [OperationContract]
        MSEBindingElement GetMSEBindingElement(Guid ID);

        [OperationContract]
        MSEBindingElementList ListMSEBindingElements();

        [OperationContract]
        void AssignBindingElementsToBinding(Guid bindingID, Guid bindingElementID, int elementOrder);

        [OperationContract]
        void RemoveBindingElementsFromBinding(Guid bindingID, Guid bindingElementID, int elementOrder);


        [OperationContract]
        Guid CreateSystem(System system);

        [OperationContract]
        void DeleteSystem(Guid ID);

        [OperationContract]
        System UpdateSystem(System system);

        [OperationContract]
        System GetSystem(Guid ID);

        [OperationContract]
        SystemList ListSystems();

        [OperationContract]
        Guid CreateSystemInstance(SystemInstance systemInstance);

        [OperationContract]
        void DeleteSystemInstance(Guid ID);

        [OperationContract]
        SystemInstance UpdateSystemInstance(SystemInstance systemInstance);

        [OperationContract]
        SystemInstance GetSystemInstance(Guid ID);

        [OperationContract]
        SystemInstanceList ListSystemInstances();

        [OperationContract]
        Guid CreateResource(Resource resource);

        [OperationContract]
        void DeleteResource(Guid ID);

        [OperationContract]
        Resource UpdateResource(Resource resource);

        [OperationContract]
        Resource GetResource(Guid ID);

        [OperationContract]
        ResourceList ListResources();

        [OperationContract]
        List<Guid> ImportSchemas(List<Schema> importedSchemas);

        [OperationContract]
        Schema GetSchema(Guid ID);

        [OperationContract]
        SchemaList ListSchemas();

        [OperationContract]
        List<Entity> ListSchemaObjectReferences(Guid ID);

        [OperationContract]
        List<SchemaObject> ListSchemaObjectDependencies(Guid ID);

        [OperationContract]
        Schema UpdateSchema(Schema schema);

        [OperationContract]
        void ValidateSchema(Schema schema);

        [OperationContract]
        void DeleteSchema(Guid ID);

        #region Archiver Support Methods

        [OperationContract]
        SchemaObject GetEquivalentSchemaObject(SchemaObject schemaObject);

        [OperationContract]
        List<Schema> ListSchemasForExport(List<Entity> entities);

        [OperationContract]
        void SaveSchemasFromImport(List<Schema> schemas);

        [OperationContract]
        SchemaObject GetSchemaObjectByNameTypeAndNamespace(string namespaceUri, string name, SchemaObjectType type);

        [OperationContract]
        List<SchemaObject> ListSchemaObjectByNameTypeAndNamespace(string namespaceUri, string name, SchemaObjectType type);

        #endregion Archiver Support Methods

        [OperationContract]
        SchemaObject GetSchemaObjectByID(Guid schemaObjectID);

        [OperationContract]
        void UpdateSchemaObjectReferences(List<Guid> oldSchemaObjectIDs, Guid newSchemaObjectID, bool removeOldVersion);

        [OperationContract]
        DataEntity GetDataEntity(Guid ID);

        [OperationContract]
        DataEntity CreateDataEntity(DataEntity dataEntity);

        [OperationContract]
        DataEntityList ListDataEntities();

        [OperationContract]
        DataEntity UpdateDataEntity(DataEntity dataEntity);

        [OperationContract]
        void DeleteDataEntity(Guid ID);

        [OperationContract]
        OperationList ListOperations();

        [OperationContract]
        OperationList ListOperationsBySchema(Guid schemaID);

        [OperationContract]
        OperationList ListOperationsByResource(Guid schemaID);

        [OperationContract]
        Guid CreateOperation(Operation operation);

        [OperationContract]
        void DeleteOperation(Guid ID);

        [OperationContract]
        Guid CreateOperationVersion(OperationVersion operationVersion);

        [OperationContract]
        void DeleteOperationVersion(Guid ID);

        [OperationContract]
        Operation UpdateOperation(Operation operation);

        [OperationContract]
        OperationVersion UpdateOperationVersion(OperationVersion operationVersion);

        [OperationContract]
        OperationVersion GetOperationVersion(Guid ID);

        [OperationContract]
        void AssignAssociatedOperationVerToEndpoint(Guid operationVersionID, Guid endpointID);

        [OperationContract]
        void AssignPublishedOperationVerToEndpoint(Guid operationVersionID, Guid endpointID);

        [OperationContract]
        void RemoveAssociatedOperationVerForEndpoint(Guid operationVersionID, Guid endpointID);

        [OperationContract]
        void RemovePublishedOperationVerForEndpoint(Guid operationVersionID, Guid endpointID);

        //Operation Groups

        [OperationContract]
        OperationGroup CreateOperationGroup(OperationGroup operationGroup);

        [OperationContract]
        OperationGroup UpdateOperationGroup(OperationGroup operationGroup);

        [OperationContract]
        OperationGroup GetOperationGroup(Guid ID);

        [OperationContract]
        void DeleteOperationGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListEntityGroups();

        [OperationContract]
        EntityGroupList ListOperationGroups();

        [OperationContract]
        EntityGroupList ListOperationGroupsByOperation(Guid operationID);

        [OperationContract]
        List<OperationListElement> ListOperationsByGroup(Guid ID);

        //Endpoint Groups

        [OperationContract]
        EndpointGroup CreateEndpointGroup(EndpointGroup endpointGroup);

        [OperationContract]
        EndpointGroup UpdateEndpointGroup(EndpointGroup operationGroup);

        [OperationContract]
        EndpointGroup GetEndpointGroup(Guid ID);

        [OperationContract]
        void DeleteEndpointGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListEndpointGroups();

        [OperationContract]
        EntityGroupList ListEndpointGroupsByEndpoint(Guid endpointID);

        [OperationContract]
        List<EndpointListElement> ListEndpointsByGroup(Guid ID);

        //System Groups

        [OperationContract]
        SystemGroup CreateSystemGroup(SystemGroup systemGroup);

        [OperationContract]
        SystemGroup UpdateSystemGroup(SystemGroup systemGroup);

        [OperationContract]
        SystemGroup GetSystemGroup(Guid ID);

        [OperationContract]
        void DeleteSystemGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListSystemGroups();

        [OperationContract]
        EntityGroupList ListSystemGroupsBySystem(Guid systemID);

        [OperationContract]
        List<SystemListElement> ListSystemsByGroup(Guid ID);



        //SystemInstance Groups

        [OperationContract]
        SystemInstanceGroup CreateSystemInstanceGroup(SystemInstanceGroup systemInstanceGroup);

        [OperationContract]
        SystemInstanceGroup UpdateSystemInstanceGroup(SystemInstanceGroup systemInstanceGroup);

        [OperationContract]
        SystemInstanceGroup GetSystemInstanceGroup(Guid ID);

        [OperationContract]
        void DeleteSystemInstanceGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListSystemInstanceGroups();

        [OperationContract]
        EntityGroupList ListSystemInstanceGroupsBySystemInstance(Guid systemInstanceID);

        [OperationContract]
        List<SystemInstanceListElement> ListSystemInstancesByGroup(Guid ID);

        //Resource Groups

        [OperationContract]
        ResourceGroup CreateResourceGroup(ResourceGroup resourceGroup);

        [OperationContract]
        ResourceGroup UpdateResourceGroup(ResourceGroup resourceGroup);

        [OperationContract]
        ResourceGroup GetResourceGroup(Guid ID);

        [OperationContract]
        void DeleteResourceGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListResourceGroups();

        [OperationContract]
        EntityGroupList ListResourceGroupsByResource(Guid resourceID);

        [OperationContract]
        List<ResourceListElement> ListResourcesByGroup(Guid ID);

        //MSEBinding Groups

        [OperationContract]
        MSEBindingGroup CreateMSEBindingGroup(MSEBindingGroup mseBinding);

        [OperationContract]
        MSEBindingGroup UpdateMSEBindingGroup(MSEBindingGroup mseBinding);

        [OperationContract]
        MSEBindingGroup GetMSEBindingGroup(Guid ID);

        [OperationContract]
        void DeleteMSEBindingGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListMSEBindingGroups();

        [OperationContract]
        EntityGroupList ListMSEBindingGroupsByMSEBinding(Guid mseBindingID);

        [OperationContract]
        List<MSEBindingListElement> ListMSEBindingsByGroup(Guid ID);

        //Schema Groups

        [OperationContract]
        SchemaGroup CreateSchemaGroup(SchemaGroup schemaGroup);

        [OperationContract]
        SchemaGroup UpdateSchemaGroup(SchemaGroup schemaGroup);

        [OperationContract]
        SchemaGroup GetSchemaGroup(Guid ID);

        [OperationContract]
        void DeleteSchemaGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListSchemaGroups();

        [OperationContract]
        EntityGroupList ListSchemaGroupsBySchema(Guid schemaID);

        [OperationContract]
        List<SchemaListElement> ListSchemasByGroup(Guid ID);

        //DataEntity Groups

        [OperationContract]
        DataEntityGroup CreateDataEntityGroup(DataEntityGroup dataEntityGroup);

        [OperationContract]
        DataEntityGroup UpdateDataEntityGroup(DataEntityGroup dataEntityGroup);

        [OperationContract]
        DataEntityGroup GetDataEntityGroup(Guid ID);

        [OperationContract]
        void DeleteDataEntityGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListDataEntityGroups();

        [OperationContract]
        EntityGroupList ListDataEntityGroupsByDataEntity(Guid dataEntityID);

        [OperationContract]
        List<DataEntityListElement> ListDataEntitiesByGroup(Guid ID);

        //Runtime Server Groups

        [OperationContract]
        RuntimeServerGroup CreateRuntimeServerGroup(RuntimeServerGroup runtimeServerGroup);

        [OperationContract]
        RuntimeServerGroup UpdateRuntimeServerGroup(RuntimeServerGroup runtimeServerGroup);

        [OperationContract]
        RuntimeServerGroup GetRuntimeServerGroup(Guid ID);

        [OperationContract]
        void DeleteRuntimeServerGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListRuntimeServerGroups();

        [OperationContract]
        EntityGroupList ListRuntimeServerGroupsByRuntimeServer(Guid runtimeServerID);

        [OperationContract]
        List<RuntimeServerListElement> ListRuntimeServersByGroup(Guid ID);

        //Channel Groups

        [OperationContract]
        ChannelGroup CreateChannelGroup(ChannelGroup channelGroup);

        [OperationContract]
        ChannelGroup UpdateChannelGroup(ChannelGroup channelGroup);

        [OperationContract]
        ChannelGroup GetChannelGroup(Guid ID);

        [OperationContract]
        void DeleteChannelGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListChannelGroups();

        [OperationContract]
        EntityGroupList ListChannelGroupsByChannel(Guid channelID);

        [OperationContract]
        List<ChannelListElement> ListChannelsByGroup(Guid ID);

        //Policy Groups

        [OperationContract]
        PolicyGroup CreatePolicyGroup(PolicyGroup poicyGroup);

        [OperationContract]
        PolicyGroup UpdatePolicyGroup(PolicyGroup policyGroup);

        [OperationContract]
        PolicyGroup GetPolicyGroup(Guid ID);

        [OperationContract]
        void DeletePolicyGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListPolicyGroups();

        [OperationContract]
        EntityGroupList ListPolicyGroupsByPolicy(Guid policyID);

        [OperationContract]
        List<PolicyListElement> ListPolicysByGroup(Guid ID);

        //Policy Assertion Groups

        [OperationContract]
        PolicyAssertionGroup CreatePolicyAssertionGroup(PolicyAssertionGroup policyAssertionGroup);

        [OperationContract]
        PolicyAssertionGroup UpdatePolicyAssertionGroup(PolicyAssertionGroup policyAssertionGroup);

        [OperationContract]
        PolicyAssertionGroup GetPolicyAssertionGroup(Guid ID);

        [OperationContract]
        void DeletePolicyAssertionGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListPolicyAssertionGroups();

        [OperationContract]
        EntityGroupList ListPolicyAssertionGroupsByPolicyAssertion(Guid policyAssertionID);

        [OperationContract]
        List<PolicyAssertionListElement> ListPolicyAssertionsByGroup(Guid ID);

        //Assertion Type Groups

        [OperationContract]
        AssertionTypeGroup CreateAssertionTypeGroup(AssertionTypeGroup assertionTypeGroup);

        [OperationContract]
        AssertionTypeGroup UpdateAssertionTypeGroup(AssertionTypeGroup assertionTypeGroup);

        [OperationContract]
        AssertionTypeGroup GetAssertionTypeGroup(Guid ID);

        [OperationContract]
        void DeleteAssertionTypeGroup(Guid ID);

        [OperationContract]
        EntityGroupList ListAssertionTypeGroups();

        [OperationContract]
        EntityGroupList ListAssertionTypeGroupsByAssertionType(Guid assertionTypeID);

        [OperationContract]
        List<AssertionTypeListElement> ListAssertionTypesByGroup(Guid ID);

        [OperationContract]
        void PublishRuntimeServerEndPointsToUddi(Guid ID, bool refresh);

        [OperationContract]
        void RemoveRuntimeServerEndPointsFromUddi(Guid ID);

        [OperationContract]
        bool IsUddiIntegrationEnabled();

        [OperationContract]
        Guid CreateAssertionType(AssertionType assertionType);

        [OperationContract]
        void DeleteAssertionType(Guid ID);

        [OperationContract]
        AssertionType GetAssertionType(Guid ID);

        [OperationContract]
        AssertionTypeList ListAssertionType();

        [OperationContract]
        AssertionType UpdateAssertionType(AssertionType assertionType);

        [OperationContract]        
        void AssignPolicyAssertionToPolicy(Guid policyID, Guid policyAssertionID, int assertionOrder);

        [OperationContract]        
        void RemovePolicyAssertionFromPolicy(Guid policyID, Guid policyAssertionID);

        [OperationContract]        
        Guid CreatePolicyAssertion(PolicyAssertion policyAssertion);

        [OperationContract]        
        void DeletePolicyAssertion(Guid ID);

        [OperationContract]        
        PolicyAssertion UpdatePolicyAssertion(PolicyAssertion policyAssertion);

        [OperationContract]
        PolicyAssertion GetPolicyAssertion(Guid ID);

        [OperationContract]        
        PolicyAssertionList ListPolicyAssertions();

        [OperationContract]        
        PolicyAssertionList ListPolicyAssertionsByPolicy(Guid policyID);

        [OperationContract] 
        void AssignSubjectToAssertionType(EntityClass entityClass, Guid assertionTypeID);

        [OperationContract] 
        void RemoveAllSubjectsFromAssertionType(Guid assertionTypeID);

        [OperationContract] 
        EntityClass[] GetAssertionTypeSubjects(Guid assertionTypeID);
    }
}
